package WhatGUI;

import java.awt.*;
import java.awt.event.*;

public class WhatDialog extends Dialog implements ActionListener{

	public WhatDialog(Frame frame, String title) {
		super(frame, title);
		addWindowListener( new WindowAdapter () {
	    	public void windowClosing(WindowEvent e) {
	        	setVisible(false);
	    	}
	    });
		
		setLocation(320, 300);
		setSize(220, 80);
		setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
		setBackground(Color.LIGHT_GRAY);

		//ボタンの設定
		Button btnYes = new Button("はい");
		Button btnNo = new Button("いいえ");
		
		Font f =  new Font  ("Dialog", Font.PLAIN, 14);
		btnYes.setFont (f);
		btnNo.setFont (f);
		btnYes.setForeground(new Color(255, 0, 0));

		btnYes.addActionListener(this);
		btnNo.addActionListener(this);

		add(btnYes);
		add(btnNo);
	}

	    

	@Override
	public void actionPerformed(ActionEvent e) {
		String str = e.getActionCommand();
		if(str.equals("はい")){
			System.exit(0);
		}else if(str.equals("いいえ")){
			setVisible(false);
		}
	}

}
